<template>
  <div></div>
</template>

<script>
import card from '@/components/card'
import { requestPost } from '@/utils/index'
export default {
  data () {
    return {}
  },
  onLoad (options) {
    this.bindParent(this.$root.$mp.query.pid)
  },
  components: {
    card
  },
  methods: {
    bindParent (pid) {
      wx.login({
        success: (res) => {
          var data = {
            'jscode': res.code,
            'pid': pid
          }
          requestPost(mpvue.getStorageSync('requestUrl') + '/miniprogram/bindParent1', data, 'POST').then(function (value) {
            if (value.code === 0) {
              mpvue.setStorageSync('openId', value.data.openId)
              mpvue.setStorageSync('userId', value.data.userId)
              mpvue.setStorageSync('token', value.data.token)
              wx.navigateTo({
                url: '/pages/good/main'
              })
            }
          }, function (value) {
            console.log('获取错误')
          })
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
